Ext.define('Dashboard.Curdtool', {
	extend : 'Ext.toolbar.Toolbar',
	alias : 'widget.Curdtool',
	items : [
		{
			text : '新增',
			//https://fontawesome.com/cheatsheet?from=io
			glyph : 'xf067@FontAwesome',
			handler: function(){
				var grid = this.findParentByType('grid');
				console.log('grid:%o',grid);
				if (grid) {
					grid.showAddWin();
				}
			}
		},
		'-',
		//		{
		//			text : '编辑',
		////			iconCls : 'x-fa fa-edit',
		//			glyph: 'xf044@FontAwesome'
		//		//handler: 'editWin'
		//		},
		//		{
		//			text : '删除',
		//			glyph: 'xf00d@FontAwesome'
		//		//handler: 'del'
		//		},
		{
			text : '查询',
			id : 'searchBtn',
			glyph : 'xf002@FontAwesome',
			handler: function(){
				var grid = this.findParentByType('grid');
				if (grid) {
					grid.onSearch(this);
				}
			}
		},
		'-',
		{
			text : '重置',
			glyph: 'xf021@FontAwesome',
			handler: function(){
				var grid = this.findParentByType('grid');
				if (grid) {
					let items = grid.query('[xtype=toolbar][dock=top]')[0].query('');
					for (let i = 0, l = items.length; i < l; i++) {
						try {
							let item = items[i];
							item.reset();
						} catch (e) {}
					}
					let cmbs = grid.query('[xtype*=MemberCmb]');
					Ext.Array.each(cmbs, function(cmb) {
						console.log('reset cmb:%o',cmb)
						cmb.setValue('');
						cmb.setRawValue('');
				    });

				}
			}
		}
	]
});